package io.renren.common.base;

/****
 * @date: 2024/3/18 15:29
 * @author liangpei
 *  token校验返回的code和msg
 */
public enum OpenApiCodeEnum {


    TOKEN_IS_NULL(10001, "token不能为空"),
    INVALID_TOKEN(10002, "签名不匹配"),
    ERROR_FORMAT_TOKEN(10003, "格式不正确"),
    EXPIRED_TOKEN(10004, "token已过期"),
    UNSUPPORTED_TOKEN(10005, "未知token"),
    APPID_IS_NULL(10006, "appId不能为空"),

    CONFIG_IS_NULL(10006, "appId不合法"),

    TOKEN_ERROR(10007, "token校验失败"),
    SIGN_ERROR(10008, "签名验签失败"),

    SIGN_DECRYPT_ERROR(10009, "签名解密失败"),
    // 对外展示
    INVENTORY_SHORTAGE(10010, "库存不足"),

    SYSTEM_ERROR(99999, "系统异常,请联系相关人员"),
    ;

    private final int code;
    private final String msg;

    OpenApiCodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static OpenApiCodeEnum getByCode(int code) {
        for (OpenApiCodeEnum errorCode : values()) {
            if (errorCode.code == code) {
                return errorCode;
            }
        }
        return null;
    }
}
